/**
  ******************************************************************************
  * @file   : uart.h
  * @author : 测试1组（houtiezhu）
  * @version: v0
  * @date   : 2019.07.09
  * @brief  : 
  *           
  * Copyright (C) 2019  Hangzhou SDIC Microelectronics Co., Ltd
  ******************************************************************************
**/

#ifndef FLASH_H
#define FLASH_H
#include "define.h"

//===============================EEP ADDR===================================
#define BootAddress			(0x08000000 + 1024 * 120)

#define UserStartAddress    (0x08000000 + 1024 * 100)
#define UserStartBak        (0x08000000 + 1024 * 100 + 512)	//记忆区
#define	SpecialAdd			(0x08000000 + 1024 * 117)
#define	SpecialBak			(0x08000000 + 1024 * 117 + 512)	//预留区
#define	 FunctionAdd		(0x08000000 + 1024 * 118)               
#define	 FunctionBak		(0x08000000 + 1024 * 118 + 512)	//功能代码区  
#define 	CalAdd			(0x08000000 + 1024 * 119)//0x1FFF8400						//校正值区
#define 	CalBak			(0x08000000 + 1024 * 119 + 512)//0x1FFF8600
#define	 FlashEnd			0x1FFF8800

#define EEPROMinMax				(1070-1)
#define UserSetAdd			EEPROMinMax
#define lifetimeadd			(EEPROMinMax-1)
#define valveoffsetAdd		(EEPROMinMax-2)
#define WorkModeAdd			(EEPROMinMax-3)
//待定

//MemBack = 2k ,所以AB总数不能大于2K
#define	UserBOffSet		501//	256	  //2048/8=256  


//============================================================================
extern	uint16   MemoryEndIndex;
extern	uint16   MemoryFirstIndex;



extern  u32 MemBack[512/4];
extern	u8   	outbyte[16];
extern	uint16   MemoryIndex;
extern	u16		MemoryEndAdd;
extern	u16		MemoryFirstAdd;	

extern	u16		MemoryCurrentIndex;//当前翻页笔数
extern	u16		MemoryDispIndex;//当前显示数字，某些客户会反过来
extern	u16		MemoryCurrentAdd;//当前地址
extern	u16		MemoryPreAdd;//早一笔地址
extern	u16		MemoryPostAdd;//后一笔地址
extern	uint8 	BPLevelType;
extern	uint16   Det_DIA;
extern	uint8   ResultDataS; 		 	//SYS     
extern	uint8   ResultDataD; 		 	//DIA      
extern	uint8   ResultDataH; 		 	//PUL      
extern	uint8   ResultDataDA;		 	//day     
extern	uint8   ResultDataHO;		 	//hour     
extern	uint8   ResultDataMI;		 	//min  

void	User_Uart0_Init(void);
void	CLRMemoryBank(void);
void	UserflashTest(void);
uint8	FLASH_PageErase(u32 AddrStart,u16 PageLength );
void	resultdata(void);
void	savefunction(void);
void	writeFULLmemorybank(void);
void	SaveSet(void);
u8 ReadSecData(u32 AddrStart);
void	writeM24L16(void);
void	readM24L16(void);

void	LoadMemory(void);
void	checkeeprom(void);
void	savecal(void);

#endif 



/************************ (C) COPYRIGHT Hangzhou SDIC Microelectronics *****END OF FILE****/